package com.slt.android.bookcontenprovider;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * 自定义provider的几个重点
 * 1.要供外部应用使用的话android:expored = true;
 * 2.给provider设置权限时(){
 *     1.在provider所在的应用的Mainifest。Application同级需要定义<permission android：name = "com.xxx.xxx.??"/>标签
 *     2.android:protectionLevel 保护级别，signature ,normal等。
 *     3.在<provider标签中 设置android:permission="com.xxx.xxx.??"/>
 *     4.如果本应用要使用这个provider，需要设置<use-permission android:name="com.xxx.xxx.??"/>
 *     5.其他任何应用要使用这个provider都要配置<use-permission android:name="com.xxx.xxx.??"/>
 *     <关于自定义permission的更多用法:https://blog.csdn.net/wh_19910525/article/details/48543487>
 *     6.上面的com.xxx.xxx.?? 不要写无意义的字符串，应写成provider所在的工程包名.XX
 * }
 *
 *
 * Created by dp on 2018/3/27.
 */

public class BookProvider extends ContentProvider {

    public static final String TAG = "yqrLog";
    @Override
    public boolean onCreate() {
        Log.d(TAG , "onCreate , current thread:" + Thread.currentThread().getName());
        return false;
    }

    @Nullable
    @Override
    public Cursor query(@NonNull Uri uri, @Nullable String[] strings, @Nullable String s, @Nullable String[] strings1, @Nullable String s1) {
        Log.d(TAG , "onCreate , current thread:" + Thread.currentThread().getName());
        return null;
    }

    @Nullable
    @Override
    public String getType(@NonNull Uri uri) {
        Log.d(TAG , "getType");
        return null;
    }

    @Nullable
    @Override
    public Uri insert(@NonNull Uri uri, @Nullable ContentValues contentValues) {
        Log.d(TAG , "insert");
        return null;
    }

    @Override
    public int delete(@NonNull Uri uri, @Nullable String s, @Nullable String[] strings) {
        Log.d(TAG , "delete");
        return 0;
    }

    @Override
    public int update(@NonNull Uri uri, @Nullable ContentValues contentValues, @Nullable String s, @Nullable String[] strings) {
        Log.d(TAG , "update");
        return 0;
    }
}
